import { createRouter, createWebHistory } from "vue-router";

const routes = [
  {
    path: '/',
    redirect: '/home',
  },
  {
    path: '/home',
    name: 'Home',
    component: () => import('@/views/Home.vue'),
  },
  {
    path: '/menu',
    name: 'Menu',
    component: () => import('@/views/Menu.vue'),
  },
  {
    path: '/community',
    name: 'Community',
    component: () => import('@/views/Community.vue'),
  },
  {
    path: '/detailCook',
    name: 'detailCook',
    component: () => import('@/views/detailCook.vue'),
  },
  {
    path: '/person',
    name: 'Person',
    component: () => import('@/views/Person.vue'),
  },
  {
    path: '/identify',
    name: 'Identify',
    component: () => import('@/views/Identify.vue'),
  },
  {
    path: '/cookStep',
    name: 'cookStep',
    component: () => import('@/views/cookStep.vue'),
    props: route => ({ dishName: route.query.dishName }) // 使用查询参数作为 props
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/Login.vue'),
  },
  {
    path: '/foodDetail',
    name: 'foodDetail',
    component: () => import('@/views/foodDetail.vue'),
    props: route => ({ id: route.query.id, token: route.query.token }) // 使用查询参数作为 props
  },
  {
    path: '/editCook',
    name: 'editCook',
    component: () => import('@/views/editCook.vue'),
    props: route => ({ id: route.query.id }) // 使用查询参数作为 props
  },
  {
    path: '/search',
    name: 'search',
    component: () => import('@/views/search.vue'),
  },
  {
    path: '/chatBot',
    name: 'chatBot',
    component: () => import('@/views/chatBot.vue'),
  },
]

const router = createRouter({
  history: createWebHistory(),
  routes,
})

export default router;